package cn.yunhe.controller;

import cn.yunhe.entity.User;
import cn.yunhe.entity.UserExamHistory;
import cn.yunhe.service.UserExamHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.json.MappingJackson2JsonView;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class UserExamHistoryController {
    @Autowired
    @Qualifier("userExamHistoryService")
    private UserExamHistoryService userExamHistoryService;
    @RequestMapping("/getuserexamhistory")
    public ModelAndView getUserExamHistory(HttpSession session){
        ModelAndView mv = new ModelAndView();
        User user  = (User) session.getAttribute("Curr_User");
        List<UserExamHistory> userExamHistoryList =  userExamHistoryService.UserExamHistory(user.getUserName());
        mv.addObject("userExamHistoryList",userExamHistoryList);
        mv.setViewName("exam-history");
        return  mv;
    }
}
